#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
import time
from rclpy.qos import QoSProfile, QoSReliabilityPolicy, QoSDurabilityPolicy

class ROS2Publisher(Node):
    def __init__(self):
        super().__init__('ros2_publisher')
        qos = QoSProfile(
            reliability=QoSReliabilityPolicy.RELIABLE,  
            durability=QoSDurabilityPolicy.VOLATILE,       
            depth=10
        )
        self.publisher = self.create_publisher(String, 'throughput_topic', qos)
        self.timer = self.create_timer(0.001, self.publish_msg)  # 1kHz
        self.msg = String()
        self.msg.data = "x" * 1024  

    def publish_msg(self):
        self.publisher.publish(self.msg)

def main():
    rclpy.init()
    node = ROS2Publisher()
    rclpy.spin(node)
    node.destroy_node()
    rclpy.shutdown()

if __name__ == '__main__':
    main()